package com.bxl.netty.rpc.common.message;

/**
 * <>
 *
 * @author baixl
 * @date 2021/3/6
 */
public class BaseResponse {
    private int code;
    private String msg;
    private Object data;

    private BaseResponse() {
    }

    private BaseResponse(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public BaseResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static BaseResponse success() {
        return new BaseResponse(0, "成功");
    }

    public static BaseResponse success(Object data) {
        return new BaseResponse(0, "成功", data);
    }

    public static BaseResponse fail(String msg) {
        return new BaseResponse(-1, msg);
    }
    
    public static BaseResponse create(int code, String msg, Object data){
        return new BaseResponse(code,msg,data);
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public Object getData() {
        return data;
    }
}
